package com.voiceblog.action;

import java.util.Date;

import com.voiceblog.model.Blog;
import com.voiceblog.model.Comment;
import com.voiceblog.model.Users;

public class addComment extends BaseAction  {

	private int articleId;
    private	String commentContent;
	private Comment comment;
	private String account;
	private Blog blog;

	private Users blogUser;
	
	




	public String addComment() throws Exception{
	
        blogUser = (Users) this.getSession().get("blogUser");
   
		blog = getDao().findById(articleId);
	    comment = new Comment();
	    comment.setCommentContent(commentContent);
	    System.out.print(blogUser.getAccount());

	    comment.setUsers(blogUser);
	    comment.setBlog(blog);
		Date date = new Date();  
		date.getDate();
	    comment.setCommentDate(date);
	   
	    getDao().saveComment(comment);
		return SUCCESS;
	}

	public int getArticleId() {
		return articleId;
	}
	public void setArticleId(int articleId) {
		this.articleId = articleId;
	}
	public String getCommentContent() {
		return commentContent;
	}
	public void setCommentContent(String commentContent) {
		this.commentContent = commentContent;
	}

	public Comment getComment() {
		return comment;
	}

	public void setComment(Comment comment) {
		this.comment = comment;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public Blog getBlog() {
		return blog;
	}

	public void setBlog(Blog blog) {
		this.blog = blog;
	}
	
	
}
